package com.kuzufang.modules.search;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.kuzufang.R;
import com.kuzufang.base.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by songyuanjin on 2017/9/28.
 */

public class SubWayStationGridAdapter extends BaseAdapter<String, SubWayStationGridAdapter.SubWayHolder> {
    private String[] subStations = new String[]{
            "莘庄",
            "外环路",
            "莲花路",
            "锦江乐园",
            "上海南站",
            "漕宝路",
            "上海体育馆",
            "徐家汇",
            "衡山路",
            "常熟路",
            "陕西南路",
            "黄陂南路",
            "人民广场",
            "新闸路",
            "汉中路",
            "上海火车站",
            "中山北路",
            "延长路",
            "上海马戏城",
            "汶水路",
            "彭浦新村",
            "共康路",
            "通河新村",
            "呼兰路",
            "共富新村 ",
            "宝安公路",
            "友谊西路",
            "富锦路"
    };

    public SubWayStationGridAdapter(Context ctx) {
        super(ctx);
        List<String> strings = new ArrayList<>();
        for (int i = 0; i < subStations.length; i++) {
            strings.add(subStations[i]);
        }
        clear();
        addAll(strings);
        notifyDataSetChanged();
    }

    @Override
    protected void bindViewHolderData(SubWayStationGridAdapter.SubWayHolder viewHolder, String data, int position) {
        viewHolder.bindData(data, position);
    }

    @Override
    public SubWayStationGridAdapter.SubWayHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mCtx).inflate(R.layout.item_subway_station, parent, false);
        return new SubWayHolder(view);
    }

    class SubWayHolder extends RecyclerView.ViewHolder {
        private TextView mSubWayLineTextView;

        public SubWayHolder(View itemView) {
            super(itemView);
            mSubWayLineTextView = (TextView) itemView.findViewById(R.id.tv_subway_line);
        }

        public void bindData(String data, int position) {
            mSubWayLineTextView.setText(data);

        }
    }


}
